package test20230421;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/4/21 18:23
 */
public class Main01 {

    public static void main(String[] args) {
        Person p1 = new Person("小黄", 21, 1.75, 73);
        p1.out();
        System.out.println("================================================");
        Person p2 = new Person("小七", 21, 1.66, 53.5);
        p2.out();
    }
}

// 人类
class Person {
    private String name; // 姓名
    private int age; // 年龄
    private double stature; // 身高(m)
    private double weight; // 体重(kg)

    // 无参构造方法
    public Person() {
    }

    // 有参构造方法
    public Person(String name, int age, double stature, double weight) {
        this.name = name;
        this.age = age;
        this.stature = stature;
        this.weight = weight;
    }

    // 正常体重：体重指数=18-25 偏瘦：体重指数<18 偏胖：体重指数>25
    // 返回体型
    public String check() {
        double BMI = weight / (stature * stature);
        if (BMI < 18) {
            return "偏瘦";
        } else if (BMI > 25) {
            return "偏胖";
        } else {
            return "正常";
        }
    }

    // 输出个人资料
    public void out() {
        System.out.println("姓名:\t" + name);
        System.out.println("年龄:\t" + age + "岁");
        System.out.println("身高:\t" + stature + "m");
        System.out.println("体重:\t" + weight + "kg");
        System.out.println("体型:\t" + check());
    }
}
